/*************************************************************************
    > File Name: map1.cpp
    > Author: cl007
    > Mail: cl007@126.com 
    > Created Time: 2016年10月09日 星期日 10时23分58秒
 ************************************************************************/
#include<map>
#include<string>
#include<iostream>
using namespace std;

int main()
{
    map<string, string> map1;
    map<int, string> map2;
    map<string, string> map3;

    map2[1] =  "helloworld";
    map1["sdsd"] = "heloolsdsa";
    map3["2123"] = "sdsada";

    map2.insert(map<int, string>::value_type(3, "sdsd"));
    map1.insert(map<string, string>::value_type("jsdsidjsi", "qwewqe"));
    map2.insert(pair<int ,string>(4,"hhhh"));
    map1.insert(pair<string, string>("232", "sdsds"));
    map1.insert(make_pair<string, string>("12123", "NNNNN"));

    map<string, string>::iterator it1;
    map<int, string>::iterator it2;

    for(it1 = map1.begin(); it1 != map1.end(); ++it1)
    {
        cout<<"map1 " << it1->first <<" = " <<  it1->second <<endl;
    }
    
    for(it2 = map2.begin(); it2 !=  map2.end(); ++it2)
    {
        cout<< "map2 " <<it2->first <<" = " <<  it2->second <<endl;
    }
    
    cout << map1.size() << endl;

    if(!map2.empty())
    {
        cout <<  "have somesing" << endl;
    }
    
    it2 =  map2.find(4);

    if(it2 != map2.end())
    {
        cout << it2->second << "    ok" <<endl; 
    }
    
    int i = map2.count(4);
   
    cout << i <<endl;
  
    map<string, string> :: reverse_iterator it3; 
    for(it3 = map1.rbegin(); it3 != map1.rend(); ++it3)
    {
        cout << it3->first<<" = " << it3->second << endl;
    }
    
    swap(map3, map1);

    for(it3 = map1.rbegin(); it3 != map1.rend(); ++it3)
    {
        cout << it3->first<<" = " << it3->second << endl;
    }

    cout << map3.size() << endl;

    it2 = map2.lower_bound(2);
   
    cout << it2->first << endl; 


    it2 = map2.upper_bound(2);
   
    cout << it2->first << endl; 
  
    return 0;
}
